/*
 * @Author: szx
 * @Date: 2022-05-21 14:19:52
 * @LastEditTime: 2022-05-21 14:32:51
 * @Description:
 * @FilePath: \leetcode\面试题\05\07\07.js
 */
/**
 * @param {number} num
 * @return {number}
 */
var exchangeBits = function (num) {
    for (let i = 0; i < 31; i += 2) {
        const a = (num >> i) & 1;
        const b = (num >> (i + 1)) & 1;
        num[i] &= a << (i + 1);
        num[i + 1] &= b << i;
    }
    return num;
};
var exchangeBits = function (num) {
    let odd = num & 0x55555555;
    //偶数
    let even = num & 0xaaaaaaaa;
    odd = odd << 1;
    even = even >>> 1;
    return odd | even;
};
